<div>
  <h2>
    <span id="health-page-heading">Diagnostics</span>
    <button mat-flat-button color="primary" (click)="refresh()"><mat-icon>refresh</mat-icon> Refresh</button>
  </h2>

  <table mat-table [dataSource]="datasource" class="mat-elevation-z8" aria-describedby="Health table">
    <ng-container matColumnDef="key">
      <th mat-header-cell *matHeaderCellDef>Service name</th>
      <td mat-cell *matCellDef="let element">{{ element.key }}</td>
    </ng-container>

    <ng-container matColumnDef="value">
      <th mat-header-cell *matHeaderCellDef>Status</th>
      <td mat-cell *matCellDef="let element">{{ element.status }}</td>
    </ng-container>

    <ng-container matColumnDef="detail">
      <th mat-header-cell *matHeaderCellDef>Details</th>
      <td mat-cell *matCellDef="let element">
        @if (element.details) {
          <button mat-icon-button aria-label="Health" (click)="showHealth(element)">
            <mat-icon>remove_red_eye</mat-icon>
          </button>
        }
      </td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
  </table>
</div>
